import json
from ronglian_sms_sdk import SmsSDK
from django.conf import settings

# accId = '2c94811c9035ff9f0192316fa00865e3'
# accToken = '357ef693d35b43a490536fcfe3528baa'
# appId = '2c94811c9035ff9f01923226669066cb'


def send_message(tid, mobile, datas):
    rly = settings.RONG_LIAN_YUN

    sdk = SmsSDK(rly.get('accId'), rly.get('accToken'), rly.get('appId'))
    # tid = '1'
    # mobile = '13898213749'
    # datas = ('7569', '3')
    resp = sdk.sendMessage(tid, mobile, datas)

    # 字符串转字段，将容联云返回的json格式的字符串转换称python中的字典格式数据
    response = json.loads(resp)

    print(resp)
    # 判断端发送是否成功，返回True False
    return response.get("statusCode") == "000000"
